<template>
	<view style="width: 100vw;height: 100vh;background-color: #F7F7F7;">
		<scroll-view :scroll-y="true" style="width: 100%;height: 100%;" :enable-back-to-top="true">
			<view id="showOrderEvaluates" class="u-demo-block">
				<view v-if="evaluate.length>1" class="u-demo-block__title" style="text-align: center;font-weight: bold;background-color: #fff;">我的订单评价</view>
				<view style="background-color: #fff;padding: 20rpx;margin: 0 0 20rpx 0;border-radius: 20rpx 20rpx 0 0;" class="u-demo-block__content" v-for="item in evaluate" :key="item.evaluateId">
					<view class="album">
						<view class="album__header">
							<view class="album__header__avatar">
								<image :src="userInfo.avatarUrl?ptUrl+userInfo.avatarUrl:''" mode=""
									style="width: 100%;height: 100%;border-radius: 50%;"></image>
							</view>
							<view class="album__header__content">
								<view style="font-size: 32rpx">{{userInfo.nickName}}</view>
								<view style="font-size: 24rpx;color: #8f9ca2">{{$u.timeFormat($timeStamp(item.createTime),'yyyy-mm-dd hh:MM:ss')}}评价</view>
							</view>
							<view style="">订单号:{{item.number}}</view>
						</view>

						<view class="album__content">
							<view style="marginBottom: 8px">
								<u--text :text="item.comment"></u--text>
							</view>
						</view>
					</view>
					<u-album v-if="item.image.length" :urls="item.image"></u-album>
					<view style="font-size: 30rpx;color: #8f9ca2">综合评分：{{item.rate}}星</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		ptUrl
	} from '@/utils/env.js'
	export default {
		data() {
			return {
				ptUrl: ptUrl,
				evaluate:[],
				userInfo:{},
			}
		},
		onLoad(options) {
			this.getUserinfo(false)
			if (options.evaluate) {
				this.evaluate = this.chuliData(JSON.parse(options.evaluate))
			}else{
				this.getAllEvaluate()
			}
		},
		methods:{
			chuliData(data){
				return data.map(e=>{
					e.image = JSON.parse(e.image).map(s=>{return this.ptUrl+s})
					return e
				}) 
			},
			getUserinfo(refresh){
				this.$http("/wx-user/userinfo","GET",{refresh:refresh}).then(res=>{
					this.userInfo = res.data.data
				})
			},
			getAllEvaluate(){
				this.$http("/evaluate/getAllEvaluate","GET",null).then(res=>{
					this.evaluate = this.chuliData(res.data.data)
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.album {
		@include flex;
		align-items: flex-start;
		flex-direction: column;

		&__header {
			flex: 1;
			display: flex;
			width: 100%;
			&__avatar {
				width: 90rpx;
				height: 90rpx;
				box-sizing: border-box;
				padding: 10rpx;
			}

			&__content {
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: center;
			}
		}

		&__content {
			flex: 1;
		}
	}
</style>
<style>
	#showOrderEvaluates .u-album {
		margin-top: 20rpx;
	}

	#showOrderEvaluates .u-album .u-album__row {
		justify-content: start;
	}

	#showOrderEvaluates .u-album .u-album__row .u-album__row__wrapper {
		max-width: 33.3%;
		flex-basis: 33.3%;
		margin: 0 !important;
		padding-bottom: 33.3%;
		position: relative;
	}

	#showOrderEvaluates .u-album .u-album__row .u-album__row__wrapper image {
		width: 95% !important;
		height: 95% !important;
		position: absolute;
	}
</style>
